Repository navigation
feat(deploy): deploy a repository that has no Composer config - #412
Closed
kristof-siket wants to merge 1 commit into
Closed
kristof-siket wants to merge 1 commit into
kristof-siket wants to merge 1 commit into
Conversation
`prisma deploy` now has two paths. A repository whose prisma.config.ts declares a `composer` section takes Composer's deploy, unchanged. Composer's own section validator decides whether the section is missing. Every other repository takes a single-app deploy. It deploys the one app in the current folder from the repository's own install, build and start commands. The rules and the deploy come from `@prisma/compute-sdk/app` (prisma/project-compute#202). The CLI adds no framework rules. - The App config is the `app` section of prisma.config.ts: install, build, start, static and port. `prisma/config` types it. - The project is the linked project or `--project`. `--environment` names the Branch. `--name` names the service; the default is the `name` in package.json, else the folder name. - The version is promoted only when the app listens. A failed install or build, a missing start, and an app that exits or opens no port each fail the deploy with a `DEPLOY.APP_*` error. - The end-to-end suite now covers `deploy` through the single-app path. `@prisma/compute-sdk/app` is not published yet, so the pinned version in package.json does not have it. `pnpm typecheck`, the builds and the tests fail on the pinned version until project-compute#202 is released and the pin is raised. They pass against the build of that pull request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
Contributor
Author
|
Closing. This wired |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prisma deploynow works in a repository that has no Prisma Composer config: it deploys the one app in the folder from the repository's own install, build and start commands.This draft was requested by Kristof Siket as part of the single-app deploy work. The rules and the deploy are a library,
@prisma/compute-sdk/app, in prisma/project-compute#202. This repository adds no framework rules and no framework names.What changed
packages/cli/src/commands/deploy/{command,config,single-app,presentation,errors}.ts,packages/cli/src/cli.tsprisma/configtypes theappsectionpackages/prisma/src/config.tspackages/cli/tests/deploy.test.tsand three structural testspackages/cli/e2e/deploy.e2e.tsdocs/,skills/,packages/*/README.md,scripts/list-error-codes.mjs18 files, 2,020 lines added, 16 removed. None of them is generated.
deployis now the shell's own command. It keeps Composer's flags (they are spread from Composer's command, so a new Composer flag arrives without a change here) and adds--project.--namehas a new brief because it names the service on a single-app deploy.appsection ofprisma.config.ts:install,build,start,static,port. All optional. An unknown field or a wrong type isCLI.CONFIG_FIELD_INVALID.definePrismaConfigfromprisma/configtypes the section, andprisma/configexportsAppConfig.--project, resolved by the same function theservicecommands use. A single-app deploy never creates a project.--environment production(the default) is the project's default Branch. Any other name is the Branch with that git name; it is created when missing.--name, else thenameinpackage.jsonwithout its scope, else the folder name. The service with that name on the Branch is reused; otherwise one is created.deploysends none. Checked for real below.x-prisma-deploy-source(github-actionwhenGITHUB_ACTIONSistrue, elsecli),x-prisma-client-name: prisma-cliandx-prisma-client-version.DEPLOY.APP_INSTALL_FAILED,DEPLOY.APP_BUILD_FAILED,DEPLOY.APP_NO_START,DEPLOY.APP_EXITED,DEPLOY.APP_SILENT,DEPLOY.APP_PORT_MISMATCH.--jsongives the usual event stream and envelope.compute-service, service id, URL.e2e-coverage.deployleaves the exclusion list. The new end-to-end test covers it through the single-app path.How the path is chosen
Composer decides. The shell's
deployreads thecomposersection through Composer's own validator (composerSection.validate):CONFIG.SECTION_MISSING: this is a single-app deploy.What I found about the other two signs named in the task:
prisma-composer.config.*is no longer read by Composer. It only produces an error.--entrynever makes a config exist. It only replacesentryinside the section.A repository with no section that still shows one of those signs is treated as a Composer app and fails with Composer's own
CONFIG.SECTION_MISSINGerror: aprisma-composer.config.*file exists, or--entrynames a file that exists. An--entrythat names no file is ignored, because prisma/cloud-deploy-action always passes--entry module.ts.One behaviour changes for Composer users:
--projecton a Composer deploy is refused (DEPLOY.APP_USAGE_ERROR) instead of being an unknown flag.Real runs
All runs used the built binary (
packages/cli/dist/cli.js) against the production Management API, in copies of the sample apps. The test projects are deleted.Server file from the build output (nuxt)
Start from a script, and an app on a fixed port (koa listens on 4123)
Static site from the build output, and a start script that runs a dev server (docusaurus)
Static site from the build output (vite-react)
Start from a script after a build (express-ts)
An app that exits at start (needs-env)
The same app after 'prisma project env add DATABASE_URL=… --role production'
No start command (sveltekit)
No start command, --json
App config override, in a prisma.config.ts that imports nothing
Entry file only (one index.ts, no package.json), deployed to another environment with the deploy action's arguments (linked project, GITHUB_ACTIONS=true, PRISMA_COMPOSER_REPORT_FILE set)
Second deploy to the same service, run as 'bun run --bun'
The branch and the service that the two runs above left
Install and build under Bun (vite-react)
No linked project and no --project
A repository with a Composer config still takes Composer's path (placeholder token, so it stops at the first API call)
App config: an unknown field
prisma.config.ts as a plain object with no marker
prisma.config.ts that imports prisma/config in a repository without the prisma package
prisma destroy, as the deploy action calls it
Running under Bun
The deploy action runs the CLI as
bun run --bun prisma. I ran the built CLI that way for three apps (a second deploy of the entry-file app, vite-react, express-ts). Install, build, upload and start behaved the same as under Node.js: same Build settings, same step results, same timings within a second.Test results
pnpm typecheckpnpm lintpnpm --filter @prisma/cli testpnpm --filter prisma testpnpm build:cli,pnpm --filter prisma buildpnpm check:error-referencepnpm check:conformance,pnpm check:skill-packaging,pnpm test:scriptse2e/deploy.e2e.tsagainst the real Management APIstartscriptsTwo things did not pass on my machine, and neither involves files this pull request changes:
pnpm testat the root fails in@prisma/cli.@prisma/cli-engine'stestscript rebuilds itsdistwhile the CLI tests import it, so those imports fail. The CLI package passes when it runs alone.pnpm --filter @prisma/cli-engine test: 2 of 1,180 tests fail (clack-prompts.test.tstimes out,spawn-real-child.test.tsexpects a process group). Both depend on the terminal of the machine.What I did not test
pnpm --filter @prisma/cli test:e2e). I ran only the new file.DEPLOY.APP_SILENT) and a stated port the app does not use (DEPLOY.APP_PORT_MISMATCH). Unit tests cover both; no sample app does this.Open questions
deployAppreads the deployment's log over a WebSocket and needs the token itself (logs: { baseUrl, token }). Commands here do not get the token, sodeploydeclaresmanagesCredentialsto read it, which only the auth commands did before. AdeployAppthat reads the log through the Management API client would remove this.prisma.config.tswithout theprismapackage. A plain default-exported object does not load: the loader stops withCLI.CONFIG_MISSING_MARKER, because an unmarked file is taken for a Prisma 7 config. A file that imports nothing does load when it carries the marker by hand:export default { $prismaConfig: 1, app: { … } }. Importingprisma/configneeds theprismapackage in the repository. I did not change the marker rule: it is a deliberate rule of the engine, and accepting unmarked files is a decision for the maintainers.deployAppreports one event after upload and first start together, andbuildAppreports its steps only when it returns. So theUploadedtime includes the wait for the app's first start, andInstalledandBuiltprint after the build ends, not as each finishes. Progress callbacks in the library would fix both.--verbosealready streams the install and build output.PRISMA_BUILD_ID, attaches the project and Branch, reports each resource, and sets the final state. A single-app deploy reports none of this yet, and it ignores--build-idand--report. In the deploy action the action itself creates the Build, reports the phases and the final state, and reads the URL from stdout (the data line contains it). What the single-app path should add: attach the project and Branch to the Build named byPRISMA_BUILD_ID, report the service and the version as resources, and set the failing step and message on failure. From a terminal it should also create the Build, so the deploy shows in the Console's history.prisma destroyis not a command in this CLI (CLI.UNKNOWN_COMMAND), so the action's destroy mode fails today for every app. For a single app, destroy should delete the service with the app's name on the environment's Branch (whatprisma service delete <name> --branch <environment>does), then delete the Branch when nothing else is on it, and refuse to run without an explicit environment. I did not add it..prisma/in the Artifact.buildAppwrites.prisma/launcher.mjsand.prisma/plan.jsoninto the app folder, next to the CLI's.prisma/local.json. For an app that is not a static site the whole folder is uploaded, includinglocal.json(a workspace id and a project id) and any.envfile in the folder.deployhas no--regionflag.DEPLOY.APP_*.DEPLOYis Composer's namespace, so I added it to the listscripts/list-error-codes.mjsscans.--environmentnaming the default Branch. Composer refuses a name other thanproductionthat is the default Branch. A single-app deploy accepts it and treats it as production.🤖 Generated with Claude Code